Contents | Index | < Browse | Browse >
LETTERctimeULETTER
Converts a time value to an ASCII string.
Overview
#include <time.h>
s = ctime(t);
char *s; // pointer to the destination string
const time_t *t;
Portability
ANSI
Description
"ctime" equals "asctime(localtime(t))": it converts a "time_t" value into
its ASCII string representation.
Returns
The function returns an ASCII string which will always be exactly 26 chars
long. The string will have the form:
"DDD MMM dd hh:mm:ss YYYY\n\0"
DDD is the weekday, MMM the month, dd is the current day in this month,
hh:mm:ss stands for Hours:Minutes:Seconds and YYYY is the current year.
For example:
"Wed Oct 25 12:05:43 1995\n\0"
The string buffer is shared among the "asctime" and "ctime"
functions.
See also
asctime , gmtime , localtime , strftime , time
Example
#include <time.h>
#include <stdio.h>
void main(void)
{
time_t t;
time(&t);
printf("The current time is %s", ctime(&t));
}